package com.iengine.services.api.command.music;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.google.gson.Gson;
import com.iengine.services.api.utils.Constant;
import com.iengine.services.api.utils.OperationName;
import com.ingine.data.pojo.HReply;

@SuppressWarnings({"unchecked","rawtypes"})
public class CommandJokeVoice extends AbstractMusicPhoneApiCommand{

	public static final String FIELD_JOKE_TYPE = "jokeType";

	/**
	 *ClassName[String]:CommandJoke
	 *	arg-list:
	 *	JokeType[String]:冷笑话
	 */
	@Override
	protected Map formatArgs(Map map, Map nlpParams) {
		HReply reply = getRemoteData(map, nlpParams);
		map = this.getFormatResult(reply,map);
		return map;
	}
	
	protected Map getFormatResult(HReply reply,Map map){
		
		Map<String,Object> resultMap =new HashMap<String,Object>();
		Map  listMap=new HashMap<String,Object>();
		listMap.put(Constant.OPERATION_NAME,OperationName.sequence.name());
		listMap.put(Constant.MUSIC_INFO, reply.getContent());
		resultMap.put(Constant.COMMAND_NAME, Constant.COMMAND_MEDIA_OPERATION);
		resultMap.put(Constant.DATA,listMap);
		map.put(Constant.COMMAND_DATA, resultMap);
		return map;
	}
	
	public String processQuery(Map map, Map nlpParams){
		Map temp = new HashMap<String, Object>();
		temp.putAll(nlpParams);
    	Object dataSize = map.get(Constant.FIELD_DATASIZE);
    	if(null != dataSize){
    		temp.putAll((Map)dataSize);
    	}
	    Map parameterMap=new HashMap();
	    temp.put(FIELD_JOKE_TYPE, "voice");
		parameterMap.put(Constant.DATA_TYPE_FIELD, Constant.JOKE_FIELD);
		parameterMap.put(Constant.PARAMS_DATA_FIELD, temp);
		return new Gson().toJson(parameterMap);
	}
	
	@Override
	public String getTTs() {
		return "正在为您加载";
	}

}
